home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLSRC.PAK / INPUTDIA.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.6 KB  |  114 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Implementation of TInputDialog.  User string input dialog box
  8. //----------------------------------------------------------------------------
  9. #pragma hdrignore SECTION
  10. #include <owl/pch.h>
  11. #if !defined(OWL_INPUTDIA_H)
  12. # include <owl/inputdia.h>
  13. #endif
  14. #if !defined(OWL_EDIT_H)
  15. # include <owl/edit.h>
  16. #endif
  17. #if !defined(OWL_VALIDATE_H)
  18. # include <owl/validate.h>
  19. #endif
  20. #include <string.h>
  21.  
  22. OWL_DIAGINFO;
  23.  
  24. #if !defined(SECTION) || SECTION == 1
  25.  
  26. //
  27. //
  28. //
  29. TInputDialog::TInputDialog(TWindow*        parent,
  30.                            const char far* title,
  31.                            const char far* prompt,
  32.                            char far*       buffer,
  33.                            int             bufferSize,
  34.                            TModule*        module,
  35.                            TValidator*     validator)
  36. :
  37.   TWindow(parent, title, module),
  38.   TDialog(parent, IDD_INPUTDIALOG, module)
  39. {
  40.   PRECONDITION(buffer);
  41.   SetCaption(title);
  42.   Prompt = strnewdup(prompt);
  43.   Buffer = buffer;
  44.   BufferSize = bufferSize;
  45.   if (validator)
  46.     (new TEdit(this,ID_INPUT))->SetValidator(validator);
  47. }
  48.  
  49. //
  50. //
  51. //
  52. TInputDialog::~TInputDialog()
  53. {
  54.   delete[] Prompt;
  55. }
  56.  
  57. //
  58. // sets and gets the values of the items (controls) of the input dialog
  59. //
  60. void
  61. TInputDialog::TransferData(TTransferDirection direction)
  62. {
  63.   if (direction == tdSetData) {
  64.     SetDlgItemText(ID_PROMPT, Prompt);
  65.     SetDlgItemText(ID_INPUT, Buffer);
  66.   }
  67.   else if (direction == tdGetData) {
  68.     GetDlgItemText(ID_INPUT, Buffer, BufferSize);
  69.   }
  70. }
  71.  
  72. //
  73. // sets the values of the items(controls) of the input dialog
  74. //
  75. void
  76. TInputDialog::SetupWindow()
  77. {
  78.   TDialog::SetupWindow();
  79.   SendDlgItemMessage(ID_INPUT, EM_LIMITTEXT, BufferSize - 1, 0);
  80. }
  81.  
  82. #endif
  83. #if !defined(SECTION) || SECTION == 2
  84.  
  85. IMPLEMENT_STREAMABLE2(TInputDialog, TDialog, TWindow);
  86.  
  87. #if !defined(BI_NO_OBJ_STREAMING)
  88.  
  89. //
  90. // reads an instance of TInputDialog from the passed ipstream
  91. //
  92. void*
  93. TInputDialog::Streamer::Read(ipstream& is, uint32 /*version*/) const
  94. {
  95.   ReadBaseObject((TDialog*)GetObject(), is);
  96.   GetObject()->Prompt = is.freadString();
  97.   return GetObject();
  98. }
  99.  
  100. //
  101. // writes the TInputDialog to the passed opstream
  102. //
  103. void
  104. TInputDialog::Streamer::Write(opstream& os) const
  105. {
  106.   WriteBaseObject((TDialog*)GetObject(), os);
  107.   os.fwriteString(GetObject()->Prompt);
  108. }
  109.  
  110.  
  111. #endif  // if !defined(BI_NO_OBJ_STREAMING)
  112.  
  113. #endif
  114.